<!--
 @description 合伙经营信息编辑/新增
 @fileName Item.vue
 @author zengqiongying
 @created 2023/04/28 14:36:41
-->
<template>
  <div>
    <Cell
      v-model="formData.name"
      title="合伙人姓名"
      placeholder="请输入"
      :maxlength="10"
      :right="false"
      is-input
      required
      inputAlign="right"
    />
    <Cell
      v-model="formData.tel"
      title="合伙人电话"
      placeholder="请输入"
      type="tel"
      :maxlength="11"
      :right="false"
      is-input
      required
      inputAlign="right"
    />
    <Cell
      v-model="formData.credentialNo"
      title="合伙人身份证号"
      placeholder="请输入"
      :maxlength="30"
      :right="false"
      is-input
      required
      inputAlign="right"
      type="tel"
    />
  </div>
</template>

<script>
  import { reactive, toRefs, defineComponent, watch } from 'vue'
  import Cell from '@/components/Cell/index.vue'
  import { initFormData } from '@/utils'
  export default defineComponent({
    name: 'DealerCustomerPartnerItem',
    components: { Cell },
    props: {
      modelValue: {
        type: Object,
        default: () => {}
      }
    },
    setup(props, { emit }) {
      const datas = reactive({
        formData: {
          name: '',
          tel: '',
          credentialNo: ''
        }
      })
      watch(
        () => props.modelValue,
        (d) => {
          initFormData(d, datas.formData)
        },
        {
          deep: true,
          immediate: true
        }
      )
      watch(
        () => datas.formData,
        (d) => {
          emit('update:modelValue', { ...props.modelValue, ...d })
        },
        {
          deep: true,
          immediate: true
        }
      )
      return {
        ...toRefs(datas)
      }
    }
  })
</script>
<style lang="less" scoped></style>
